package ui;

import base.Sex;
import com.sun.lwuit.ButtonGroup;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.RadioButton;
import com.sun.lwuit.table.TableLayout;

/**
 *
 * @author Shayan
 */
public class SexField extends Container {

    RadioButton rduMale;
    RadioButton rduFemale;
    ButtonGroup grpSex;

    public SexField() {
        this.setLayout(new TableLayout(1, 3));

        grpSex = new ButtonGroup();
        rduMale = new RadioButton("Male");
        rduFemale = new RadioButton("Female");
        grpSex.add(rduMale);
        grpSex.add(rduFemale);
        rduFemale.setSelected(true);

        this.addComponent(new Label("Sex:"));
        this.addComponent(rduMale);
        this.addComponent(rduFemale);
    }

    public boolean getSelectedSex() {
        return grpSex.getSelectedIndex() == 0 ? Sex.Male : Sex.Female;
    }
}
